home *** CD-ROM | disk | FTP | other *** search
/ The World's Largest Collection of Windows Software / The World's Largest Collection of Windows Software - Disc 1.iso / connect / _j2 / wvnsc926 / wvcncm.c < prev    next >
C/C++ Source or Header  |  1994-09-21  |  65KB  |  2,123 lines

  1. /*
  2.  *
  3.  * $Id: wvcncm.c 1.32 1994/09/19 00:24:57 jcooper Exp $
  4.  * $Log: wvcncm.c $
  5.  * Revision 1.32  1994/09/19  00:24:57  jcooper
  6.  * Disable MAPI in win32s.  Force a repaint on change of thread show-full-
  7.  * subject
  8.  *
  9.  * Revision 1.31  1994/09/16  00:46:55  jcooper
  10.  * New SmartFiler, Cc-by-mail dialogs.  massive cleanup for 92.6
  11.  * 
  12.  * Revision 1.29  1994/08/24  18:00:29  jcooper
  13.  * misc encoding/decoding changes
  14.  *
  15.  * Revision 1.28  1994/08/11  00:09:17  jcooper
  16.  * Enhancements to Mime and article encoding/encoding
  17.  *
  18.  * Revision 1.27  1994/07/25  22:41:22  pearse_w_r
  19.  * ShowUnreadOnly option
  20.  *
  21.  * Revision 1.26  1994/07/25  18:51:48  jcooper
  22.  * execution of decoded files
  23.  *
  24.  * Revision 1.25  1994/06/08  21:01:45  gardnerd
  25.  * more scrolling changes...
  26.  *
  27.  * Revision 1.24  1994/05/26  22:11:04  jglasser
  28.  * warnings
  29.  *
  30.  * Revision 1.23  1994/05/23  19:51:51  rushing
  31.  * NNTPPort becomes NNTPService, and it's a string.
  32.  *
  33.  * Revision 1.22  1994/05/23  18:37:00  jcooper
  34.  * new attach code, session [dis]connect
  35.  *
  36.  * Revision 1.21  1994/05/02  19:49:56  rushing
  37.  * changes from jody glasser
  38.  *
  39.  * Revision 1.20  1994/03/01  19:10:19  rushing
  40.  * ThreadFullSubject option added
  41.  *
  42.  * Revision 1.19  1994/02/24  21:27:28  jcoop
  43.  * jcoop changes
  44.  *
  45.  * Revision 1.18  1994/01/24  17:39:47  jcoop
  46.  * 90.2 changes
  47.  *
  48.  * Revision 1.17  1994/01/16  12:02:59  jcoop
  49.  * INI stuff now all written in winvn.c.  New dialogs for en/decoding
  50.  *
  51.  * Revision 1.16  1994/01/12  19:27:32  mrr
  52.  * mrr mods 4
  53.  * 
  54.  * Revision 1.15  1993/12/08  01:27:21  rushing
  55.  * new version box and cr lf consistency
  56.  *
  57.  * Revision 1.14  1993/08/25  18:53:17  mbretherton
  58.  * MRB merge, mail & post logging
  59.  *
  60.  *
  61.  * Bretherton
  62.  *  activate mail type after user change and add logging dialog
  63.  *
  64.  * Revision 1.13  1993/08/25  17:05:17  mbretherton
  65.  * merge from first newsrc.zip
  66.  *
  67.  *
  68.  * Bretherton
  69.  * activate mail type after user change and add logging dialog
  70.  *
  71.  * Revision 1.12  1993/08/05  20:06:07  jcoop
  72.  * save multiple articles changes by jcoop@oakb2s01.apl.com (John S Cooper)
  73.  *
  74.  * Revision 1.11  1993/07/13  16:03:04  riordan
  75.  * MRR mods
  76.  *
  77.  * Revision 1.10  1993/06/26  00:25:11  rushing
  78.  * warnings
  79.  *
  80.  * Revision 1.9  1993/06/25  20:49:28  dumoulin
  81.  * Cleaned up compiler warnings
  82.  *
  83.  * Revision 1.8  1993/06/22  19:44:42  rushing
  84.  * fixed IDD_MAIL_SELECT_AUTO
  85.  *
  86.  * Revision 1.7  1993/06/22  19:09:14  rushing
  87.  * mail force type selection via dialog
  88.  *
  89.  * Revision 1.6  1993/05/28  17:18:00  rushing
  90.  * Added Misc... option to enable threading
  91.  *
  92.  * Revision 1.5  1993/05/24  23:24:26  rushing
  93.  * change NNTPHost->SMTP Host for Comm... Dialog
  94.  *
  95.  * Revision 1.4  1993/05/18  22:10:45  rushing
  96.  * smtp support
  97.  *
  98.  * Revision 1.3  1993/05/13  19:59:11  rushing
  99.  * fancy 'from' in group window
  100.  *
  101.  * Revision 1.2  1993/05/13  16:17:00  rushing
  102.  * article fetch limit dialog box
  103.  *
  104.  * Revision 1.1  1993/02/16  20:53:50  rushing
  105.  * Initial revision
  106.  *
  107.  *
  108.  */
  109.  
  110. /*-- This is the first line of WVCNCM.C -------------------------------*/
  111.  
  112. #include <windows.h>
  113. #include <windowsx.h>
  114. #include "wvglob.h"
  115. #include "winvn.h"
  116. #pragma hdrstop
  117. #include <stdlib.h>
  118. #include <limits.h>
  119. #include <io.h>            // for _access
  120.  
  121. extern int WinVnDoComm (char *);
  122. int saveMailForceType ;
  123. void enableDemandLogonCtl( HWND hDlg, int forceType);
  124. void SetupEncodingOptions (HWND hDlg);
  125. BOOL ProcessEncodingOptions (HWND hDlg);
  126.  
  127. /*-- function WinVnCommDlg ---------------------------------------------
  128.  *
  129.  *   Dialog function to process the Configure Communications
  130.  *   dialog box.
  131.  */
  132.  
  133. BOOL FAR PASCAL 
  134. WinVnCommDlg (hDlg, iMessage, wParam, lParam)
  135.      HWND hDlg;
  136.      unsigned iMessage;
  137.      WORD wParam;
  138.      LONG lParam;
  139. {
  140. #define MAXSTR  32
  141.   static int MyCommPortID;
  142.   static int MyCommParityID;
  143.   static int MyCommModeID;
  144.   static int SaveDemand ;
  145.   static char pszMyCommSpeed[MAXCOMMSPEEDCHARS];
  146.   static char pszMyNNTPService[MAXSTR];
  147.   int mail_force_radio;
  148.   int write_ini = FALSE;
  149.   char NNTPPassword[MAXNNTPSIZE];
  150. // char *cptr;
  151.  
  152.   switch (iMessage)
  153.     {
  154.  
  155.     case WM_INITDIALOG:
  156. #if 0
  157.       if (AskComm == ASK_COMM_INITIAL)
  158.    AskComm = ASK_COMM_NEVER;
  159.       MyCommPortID = CommPortID;
  160.       MyCommParityID = CommParityID;
  161.       strcpy (pszMyCommSpeed, pszCommSpeed);
  162.       MyCommModeID = (UsingSocket ? ID_COMMTCP : ID_COMMSERIAL);
  163.  
  164.       CheckRadioButton (hDlg, IDD_COM1, IDD_COM2, CommPortID);
  165.       CheckRadioButton (hDlg, IDD_7EVEN, IDD_8NONE, CommParityID);
  166.       CheckRadioButton (hDlg, ID_COMMTCP, ID_COMMSERIAL, MyCommModeID);
  167.       CheckDlgButton (hDlg, ID_CONFIG_ASK_COMM, AskComm);
  168.       SetDlgItemText (hDlg, IDD_SPEED, pszMyCommSpeed);
  169. #endif
  170.       SetDlgItemText (hDlg, ID_CONFIG_NNTP_SERVER, NNTPHost);
  171.       SetDlgItemText (hDlg, ID_CONFIG_SMTP_SERVER, SMTPHost);
  172.       SetDlgItemText (hDlg, ID_CONFIG_NNTP_PORT, NNTPService);
  173.       SetDlgItemText (hDlg, ID_CONFIG_AUTH_USERNAME, NNTPUserName);
  174.       MRRDecrypt(NNTPPasswordEncrypted,(unsigned char *)NNTPPassword, MAXNNTPSIZE);
  175.       SetDlgItemText (hDlg, ID_CONFIG_AUTH_PASSWORD, NNTPPassword);
  176. #ifdef WIN32
  177.       if (GetVersion() == 1)    /* win32s */
  178.          EnableWindow(GetDlgItem(hDlg, IDD_MAIL_SELECT_MAPI), FALSE);
  179. #endif
  180.       saveMailForceType=MailForceType ;
  181.       if (MailForceType == -1)
  182.    mail_force_radio = IDD_MAIL_SELECT_AUTO;
  183.       else
  184.    mail_force_radio = MailForceType + IDD_MAIL_SELECT_NONE;
  185.  
  186.       CheckRadioButton (hDlg, IDD_MAIL_SELECT_NONE,
  187.          IDD_MAIL_SELECT_AUTO, mail_force_radio);
  188.  
  189.       SaveDemand = MailDemandLogon ;
  190.       CheckDlgButton (hDlg, IDD_DEMANDLOGON, SaveDemand);
  191.       enableDemandLogonCtl(hDlg,saveMailForceType) ;
  192.  
  193.       return TRUE;
  194.  
  195.       break;
  196.  
  197.     case WM_COMMAND:
  198.       switch (wParam)
  199.    {
  200.    case ID_OK_SAVE:
  201.      write_ini = TRUE;
  202.    case IDOK:
  203. #if 0
  204. /* disabled serial code... */
  205.      GetDlgItemText(hDlg, IDD_SPEED, pszCommSpeed, MAXCOMMSPEEDCHARS - 1);
  206.      CommPortID = MyCommPortID;
  207.      CommParityID = MyCommParityID;
  208.      CommIDtoStr (CommPortID, CommParityID, pszCommSpeed, szCommString);
  209.      WinVnDoComm (szCommString);
  210.  
  211.      if (Initializing)
  212.        UsingSocket = (MyCommModeID == ID_COMMTCP);
  213. #endif
  214.      UsingSocket = 1;
  215.      GetDlgItemText (hDlg, ID_CONFIG_NNTP_SERVER, NNTPHost, MAXNNTPSIZE);
  216.      GetDlgItemText (hDlg, ID_CONFIG_SMTP_SERVER, SMTPHost, MAXNNTPSIZE); 
  217.      GetDlgItemText (hDlg, ID_CONFIG_NNTP_PORT, NNTPService, MAXNNTPSIZE);
  218.      GetDlgItemText (hDlg, ID_CONFIG_AUTH_USERNAME, NNTPUserName, MAXNNTPSIZE);
  219.      GetDlgItemText (hDlg, ID_CONFIG_AUTH_PASSWORD, NNTPPassword, MAXNNTPSIZE);
  220.      MRREncrypt((unsigned char *)NNTPPassword,strlen(NNTPPassword)+1,
  221.      NNTPPasswordEncrypted);
  222.      AskComm = IsDlgButtonChecked (hDlg, ID_CONFIG_ASK_COMM);
  223.      MailDemandLogon = SaveDemand ;
  224.  
  225.  
  226. /*      if (write_ini)    (JSC - Now write on exit of app)
  227.         {
  228. //          WritePrivateProfileString
  229. //        (szAppName, "CommString", szCommString, szAppProFile);
  230.           WritePrivateProfileString
  231.         (szAppName, "NNTPHost", NNTPHost, szAppProFile);
  232.           WritePrivateProfileString
  233.         (szAppName, "SMTPHost", SMTPHost, szAppProFile);
  234.           WritePrivateProfileString
  235.         (szAppName, "NNTPService", NNTPService, szAppProFile);
  236.         WritePrivateProfileString
  237.         (szAppName, "NNTPUserName", NNTPUserName, szAppProFile);
  238.         WritePrivateProfileString
  239.         (szAppName, "NNTPPassword", NNTPPasswordEncrypted, szAppProFile);
  240.           WritePrivateProfileInt (szAppName, "MailForceType",
  241.                       saveMailForceType, szAppProFile);
  242.           WritePrivateProfileInt (szAppName, "MailDemandLogon",
  243.                       MailDemandLogon, szAppProFile);
  244.  
  245.  
  246. //         cptr = MyCommModeID == ID_COMMTCP ? "1" : "0";
  247. //         WritePrivateProfileString (szAppName, "UseSocket", cptr, szAppProFile);
  248. //         WritePrivateProfileInt (szAppName, "AskComm", AskComm, szAppProFile);
  249.  
  250.        }
  251. */
  252.      if (saveMailForceType!=MailForceType)
  253.      {/* change of mail transport medium
  254.          Not entirely correct as may change from
  255.          explicit selection to auto detect which
  256.          in this case will (but in reality may not)
  257.          affect a relogin to mail)  */
  258.          MailForceType=saveMailForceType;
  259.          MailCrashExit(hDlg);
  260.          MailInit (hDlg);
  261.          UpdateAllMailMenus();
  262.      }
  263.      EndDialog (hDlg, TRUE);
  264.      break;
  265.  
  266.    case IDCANCEL:
  267.      EndDialog (hDlg, FALSE);
  268.      break;
  269.  
  270. #if 0
  271.    case ID_COMMTCP:
  272.    case ID_COMMSERIAL:
  273.      MyCommModeID = wParam;
  274.      CheckRadioButton (hDlg, ID_COMMTCP, ID_COMMSERIAL, MyCommModeID);
  275.      break;
  276.  
  277.    case IDD_COM1:
  278.    case IDD_COM2:
  279.      MyCommPortID = wParam;
  280.      CheckRadioButton (hDlg, IDD_COM1, IDD_COM2, wParam);
  281.      break;
  282.  
  283.    case IDD_7EVEN:
  284.    case IDD_8NONE:
  285.      MyCommParityID = wParam;
  286.      CheckRadioButton (hDlg, IDD_7EVEN, IDD_8NONE, wParam);
  287.      break;
  288. #endif
  289.  
  290.    case IDD_MAIL_SELECT_NONE:
  291.    case IDD_MAIL_SELECT_MAPI:   
  292.    case IDD_MAIL_SELECT_SMTP:
  293.      saveMailForceType = wParam - IDD_MAIL_SELECT_NONE;
  294.      enableDemandLogonCtl(hDlg,saveMailForceType) ;
  295.      break;
  296.  
  297.    case IDD_MAIL_SELECT_AUTO:
  298.      saveMailForceType = -1;
  299.      enableDemandLogonCtl(hDlg,saveMailForceType) ;
  300.           break;
  301.  
  302.    case IDD_DEMANDLOGON:
  303.      SaveDemand = !SaveDemand;
  304.      CheckDlgButton (hDlg, IDD_DEMANDLOGON, SaveDemand);
  305.      break;
  306.  
  307.    default:
  308.      return FALSE;
  309.    }
  310.    break;
  311.    
  312.  default:
  313.    return FALSE;
  314.    break;
  315.  }
  316.   return TRUE;
  317. }
  318. /*
  319.  *  enable/disable the check box for the DemandLogon variable
  320.  *  as requested
  321.  *
  322.  *  some mail transports do not require authentification (logon)
  323.  *  so demand (deferred ) logon is not an option 
  324.  *
  325.  */  
  326. void enableDemandLogonCtl( HWND hDlg, int forceType)
  327. {
  328.    EnableWindow(GetDlgItem(hDlg,IDD_DEMANDLOGON),
  329.       (forceType==-1) || (forceType==MT_MAPI) );
  330. }
  331.  
  332. /*--- Function CommIDtoStr --------------------------------------
  333.  *
  334.  *   Takes information relating to comm port configuration and creates
  335.  *   a string of the form to give to the MODE command.
  336.  *
  337.  *   Entry    Port      is the port (an IDD_* variable)
  338.  *            Parity    is the parity/data bits infor (an IDD_* variable)
  339.  *            szSpeed     is the speed, in character form
  340.  *
  341.  *   Exit     CommStr    is the string; e.g., "COM1:2400,n,8"
  342.  *            Function value is non-zero if error.
  343.  */
  344. int
  345. CommIDtoStr (Port, Parity, szSpeed, CommStr)
  346.      int Port, Parity;
  347.      char *szSpeed;
  348.      char *CommStr;
  349. {
  350.   register char *ptr;
  351.  
  352.   ptr = CommStr;
  353.   strcpy (ptr, "COM");
  354.   ptr += 3;
  355.   *(ptr++) = (char) (Port == IDD_COM1 ? '1' : '2');
  356.   *(ptr++) = ':';
  357.  
  358.   for (; *szSpeed; *(ptr++) = *(szSpeed++));
  359.   *(ptr++) = ',';
  360.   if (Parity == IDD_7EVEN)
  361.     {
  362.       strcpy (ptr, "e,7");
  363.     }
  364.   else
  365.     {
  366.       strcpy (ptr, "n,8");
  367.     }
  368.  
  369.   return (0);
  370. }
  371.  
  372. /*-- function WinVnSaveArtDlg ---------------------------------------
  373.  *
  374.  *  Dialog function to handle Save Article dialog box.
  375.  */
  376.  
  377. BOOL FAR PASCAL 
  378. WinVnSaveArtDlg (hDlg, iMessage, wParam, lParam)
  379.      HWND hDlg;
  380.      unsigned iMessage;
  381.      WORD wParam;
  382.      LONG lParam;
  383. {
  384.   static int MyAppend;
  385.   char fileName[MAXFILENAME];
  386.  
  387.   switch (iMessage)
  388.     {
  389.  
  390.     case WM_INITDIALOG:
  391.       MyAppend = SaveArtAppend;
  392.  
  393.       CheckDlgButton (hDlg, IDD_APPEND, MyAppend);
  394.       SetDlgItemText (hDlg, IDD_FILENAME, SaveArtFileName);
  395.       return TRUE;
  396.       break;
  397.  
  398.     case WM_COMMAND:
  399.       switch (wParam)
  400.    {
  401.    case IDOK:
  402.      GetDlgItemText (hDlg, IDD_FILENAME, SaveArtFileName, MAXFILENAME - 1);
  403.  
  404.      SaveArtAppend = MyAppend;
  405.      if (!MRRWriteDocument (ActiveArticleDoc, sizeof (TypText), SaveArtFileName, SaveArtAppend))
  406.        {
  407.          MessageBox (hWndConf, "Could not write to file", "Problems saving file", MB_OK | MB_ICONEXCLAMATION);
  408.        }
  409.      EndDialog (hDlg, TRUE);
  410.      break;
  411.  
  412.    case ID_BROWSE:
  413.      fileName[0]='\0';
  414.      if (AskForNewFileName (hDlg, fileName, "", MyAppend) == SUCCESS)
  415.        SetDlgItemText (hDlg, IDD_FILENAME, fileName);
  416.      break;
  417.  
  418.    case IDCANCEL:
  419.      EndDialog (hDlg, FALSE);
  420.      break;
  421.  
  422.    case IDD_APPEND:
  423.      MyAppend = !MyAppend;
  424.      CheckDlgButton (hDlg, IDD_APPEND, MyAppend);
  425.      break;
  426.  
  427.    default:
  428.      return FALSE;
  429.    }
  430.       break;
  431.  
  432.     default:
  433.       return FALSE;
  434.       break;
  435.     }
  436.   return TRUE;
  437. }
  438.  
  439. /*-- function WinVnSaveArtsDlg ---------------------------------------
  440.  *
  441.  *  Dialog function to handle Save Articles dialog box.
  442.  *  Same as Save Article dialog, except actual save is deferred until
  443.  *  later (When IDM_RETRIEVE_COMPLETE Message gets sent to Group win)
  444.  *  (JSC)
  445.  */
  446.  
  447. BOOL FAR PASCAL 
  448. WinVnSaveArtsDlg (hDlg, iMessage, wParam, lParam)
  449.      HWND hDlg;
  450.      unsigned iMessage;
  451.      WORD wParam;
  452.      LONG lParam;
  453. {
  454.   static int MyAppend;
  455.   char fileName[MAXFILENAME];
  456.  
  457.   switch (iMessage)
  458.     {
  459.  
  460.     case WM_INITDIALOG:
  461.       MyAppend = SaveArtAppend;
  462.  
  463.       CheckDlgButton (hDlg, IDD_APPEND, MyAppend);
  464.       CheckDlgButton (hDlg, IDD_KEEP_HEADER_VISIBLE, KeepArticleHeaderVisible);
  465.       SetDlgItemText (hDlg, IDD_FILENAME, SaveArtFileName);
  466.       return TRUE;
  467.       break;
  468.  
  469.     case WM_COMMAND:
  470.       switch (wParam)
  471.    {
  472.    case IDOK:
  473.      GetDlgItemText (hDlg, IDD_FILENAME, SaveArtFileName, MAXFILENAME - 1);
  474.      KeepArticleHeaderVisible = IsDlgButtonChecked (hDlg, IDD_KEEP_HEADER_VISIBLE);
  475.      SaveArtAppend = MyAppend;
  476.      EndDialog (hDlg, TRUE);
  477.      break;
  478.  
  479.    case ID_BROWSE:
  480.      fileName[0]='\0';
  481.      if (AskForNewFileName (hDlg, fileName, "", MyAppend) == SUCCESS)
  482.        SetDlgItemText (hDlg, IDD_FILENAME, fileName);
  483.      break;
  484.    
  485.    case IDCANCEL:
  486.      EndDialog (hDlg, FALSE);
  487.      break;
  488.  
  489.    case IDD_APPEND:
  490.      MyAppend = !MyAppend;
  491.      CheckDlgButton (hDlg, IDD_APPEND, MyAppend);
  492.      break;
  493.  
  494.    default:
  495.      return FALSE;
  496.    }
  497.       break;
  498.  
  499.     default:
  500.       return FALSE;
  501.       break;
  502.     }
  503.   return TRUE;
  504. }
  505.  
  506. /*-- function WinVnDecodeArtsDlg ---------------------------------------
  507.  *
  508.  *  Dialog function to handle Decode Articles dialog box.
  509.  *  (JSC)
  510.  */
  511.  
  512. BOOL FAR PASCAL 
  513. WinVnDecodeArtsDlg (hDlg, iMessage, wParam, lParam)
  514.      HWND hDlg;
  515.      unsigned iMessage;
  516.      WORD wParam;
  517.      LONG lParam;
  518. {
  519.   int len;
  520.  
  521.   switch (iMessage)
  522.     {
  523.  
  524.     case WM_INITDIALOG:
  525.       SetDlgItemText (hDlg, IDD_DECODE_PATH, DecodePathName);
  526.       CheckDlgButton (hDlg, IDD_DUMB_DECODE, DumbDecode);
  527.       CheckDlgButton (hDlg, IDD_VERBOSE_STATUS, CodingStatusVerbose);
  528.       CheckDlgButton (hDlg, IDD_EXECUTE_DECODED, ExecuteDecodedFiles);
  529.       CheckDlgButton (hDlg, IDD_SMART_FILER, UseSmartFiler);
  530.       CheckDlgButton (hDlg, IDD_KEEP_HEADER_VISIBLE, KeepArticleHeaderVisible);
  531.       EnableWindow(GetDlgItem(hDlg, IDD_KEEP_HEADER_VISIBLE), (BOOL)lParam); 
  532.       if (lParam)
  533.          SetWindowText(hDlg, "Decode Articles");
  534.       else
  535.          SetWindowText(hDlg, "Decode");
  536.  
  537.       return TRUE;
  538.       break;
  539.  
  540.     case WM_COMMAND:
  541.       switch (wParam)
  542.     {
  543.     case IDOK:
  544.       GetDlgItemText (hDlg, IDD_DECODE_PATH, DecodePathName, MAXFILENAME - 1);
  545.       RemoveTrailingWhiteSpace (DecodePathName);
  546.           len = strlen(DecodePathName);
  547.       if (len == 0)
  548.       {
  549.          MessageBox (hDlg, "Please enter a path name before continuing", "Decode Path", MB_OK);
  550.         break;                                                                                                          
  551.       }
  552.  
  553.       if (DecodePathName[len-1] == '\\')
  554.          DecodePathName[len-1] = '\0';
  555.       
  556.       if (_access(DecodePathName, 0) < 0)
  557.       {
  558.          sprintf(str, "The path %s does not exist", DecodePathName);
  559.          MessageBox (hDlg, str, "Decode Path", MB_OK|MB_ICONSTOP);
  560.         break;                                                                                                          
  561.       }
  562.  
  563.         DumbDecode = IsDlgButtonChecked (hDlg, IDD_DUMB_DECODE);
  564.          CodingStatusVerbose = IsDlgButtonChecked (hDlg, IDD_VERBOSE_STATUS);
  565.       UseSmartFiler = IsDlgButtonChecked (hDlg, IDD_SMART_FILER);
  566.       KeepArticleHeaderVisible = IsDlgButtonChecked (hDlg, IDD_KEEP_HEADER_VISIBLE);
  567.       EndDialog (hDlg, TRUE);
  568.       break;
  569.  
  570.     
  571.     case ID_BROWSE:
  572.       if (AskForFilePath (hDlg, DecodePathName, "Select Decode Path") == SUCCESS)
  573.          SetDlgItemText (hDlg, IDD_DECODE_PATH, DecodePathName);
  574.       break;
  575.  
  576.     case IDCANCEL:
  577.       EndDialog (hDlg, FALSE);
  578.       break;
  579.     
  580.     case IDD_SMART_FILER:
  581.         DialogBox(hInst, "WinvnSmartFiler", hDlg, lpfnWinVnSmartFilerDlg);
  582.         break;
  583.  
  584.     default:
  585.       return FALSE;
  586.     }
  587.       break;
  588.  
  589.     default:
  590.       return FALSE;
  591.       break;
  592.     }
  593.   return TRUE;
  594. }
  595. /*-- function WinVnAttachDlg ---------------------------------------
  596.  *
  597.  *  Dialog function to handle attachments to postings
  598.  *  (JSC)
  599.  */
  600.  
  601. BOOL FAR PASCAL 
  602. WinVnAttachDlg (hDlg, iMessage, wParam, lParam)
  603.      HWND hDlg;
  604.      unsigned iMessage;
  605.      WORD wParam;
  606.      LONG lParam;
  607. {
  608.   char temp[MAXINTERNALLINE];
  609.   extern char *GetFileExtension ();
  610.   extern BOOL isnumber();
  611.   long newLen;
  612.   register int i;
  613.   int genMIME, result;
  614.   extern char *ContentTypes[NUM_CONTENT_TYPES];
  615.     
  616.   switch (iMessage)
  617.     {
  618.     case WM_INITDIALOG:
  619.     sprintf (temp, "Attachment options for file %s", AttachFileName);
  620.     SetWindowText (hDlg, (LPSTR) temp);
  621.  
  622.     CheckRadioButton (hDlg,IDD_ATTACH_NOW, IDD_ATTACH_NEXT, AttachInNewArt?IDD_ATTACH_NEXT:IDD_ATTACH_NOW);
  623.  
  624.     // this feature is only available when posting (not when mailing)
  625.         if (!getWndEdit(WndMails, GetWindow (hDlg, GW_OWNER), MAXMAILWNDS))
  626.     {
  627.         EnableWindow (GetDlgItem (hDlg, IDD_REVIEW), TRUE);        // posting
  628.         EnableWindow (GetDlgItem (hDlg, IDD_NO_REVIEW), TRUE);
  629.     }
  630.     else
  631.     {
  632.         EnableWindow (GetDlgItem (hDlg, IDD_REVIEW), FALSE);    // mailing
  633.         EnableWindow (GetDlgItem (hDlg, IDD_NO_REVIEW), FALSE);
  634.     }
  635.             
  636.     CheckRadioButton (hDlg,IDD_REVIEW, IDD_NO_REVIEW, ReviewAttach?IDD_REVIEW:IDD_NO_REVIEW);
  637.  
  638.     SendDlgItemMessage(hDlg, IDD_ARTICLE_SPLIT_LENGTH,
  639.         CB_ADDSTRING, 0, (LPARAM) ((LPSTR) "32000"));
  640.     SendDlgItemMessage(hDlg, IDD_ARTICLE_SPLIT_LENGTH,
  641.         CB_ADDSTRING, 0, (LPARAM) ((LPSTR) uitoa(MAXPOSTLENGTH, str, 10)));
  642.  
  643.     SetDlgItemText (hDlg, IDD_ARTICLE_SPLIT_LENGTH, uitoa (ArticleSplitLength, str, 10));
  644.         
  645.     SetupEncodingOptions (hDlg);
  646.  
  647.     SetDlgItemText (hDlg, IDD_SUBJECT_TEMPLATE, SubjectTemplate);
  648.  
  649.         CheckDlgButton (hDlg, IDD_GENERATE_MIME, GenerateMIME);
  650.         if (!GenerateMIME)
  651.         {
  652.         EnableWindow (GetDlgItem (hDlg, IDD_MIME_BOUNDARY), FALSE);
  653.         EnableWindow (GetDlgItem (hDlg, IDD_CONTENT_TYPE), FALSE);
  654.         EnableWindow (GetDlgItem (hDlg, IDD_MAKE_DEFAULT), FALSE);
  655.     }        
  656.         CheckDlgButton (hDlg, IDD_MIME_USAGE_SUGGESTIONS, MIMEUsageSuggestions);
  657.  
  658.     for (i = 0; i < NUM_CONTENT_TYPES; i++)
  659.         SendDlgItemMessage(hDlg, IDD_CONTENT_TYPE,
  660.             CB_ADDSTRING, 0, (LPARAM) ((LPSTR) ContentTypes[i]));
  661.  
  662.     if (_stricmp (DefaultContentType, "Other"))
  663.         SendDlgItemMessage(hDlg, IDD_CONTENT_TYPE,
  664.             CB_ADDSTRING, 0, (LPARAM) ((LPSTR) DefaultContentType));
  665.     
  666.        CheckDlgButton (hDlg, IDD_MAKE_DEFAULT, 0);
  667.  
  668.     GetFileExtension (temp, AttachFileName);
  669.     if (!_stricmp (temp, "gif"))
  670.         SendDlgItemMessage(hDlg, IDD_CONTENT_TYPE, CB_SELECTSTRING, (WPARAM)-1, (LPARAM) ((LPSTR) "Image/GIF"));
  671.     else if (!_stricmp (temp, "jpg") || !_strnicmp (temp, "jpe", 3))
  672.         SendDlgItemMessage(hDlg, IDD_CONTENT_TYPE, CB_SELECTSTRING, (WPARAM)-1, (LPARAM) ((LPSTR) "Image/JPEG"));
  673.     else if (!_stricmp (temp, "zip"))
  674.         SendDlgItemMessage(hDlg, IDD_CONTENT_TYPE, CB_SELECTSTRING, (WPARAM)-1, (LPARAM) ((LPSTR) "Application/Zip"));
  675.     else if (!_stricmp (temp, "mpg") || !_strnicmp (temp, "mpe", 3))
  676.         SendDlgItemMessage(hDlg, IDD_CONTENT_TYPE, CB_SELECTSTRING, (WPARAM)-1, (LPARAM) ((LPSTR) "Video/MPEG"));
  677.     else if (!_stricmp (temp, "avi"))                  
  678.         SendDlgItemMessage(hDlg, IDD_CONTENT_TYPE, CB_SELECTSTRING, (WPARAM)-1, (LPARAM) ((LPSTR) "Video/AVI"));
  679.     else if (!_stricmp (temp, "ps"))
  680.         SendDlgItemMessage(hDlg, IDD_CONTENT_TYPE, CB_SELECTSTRING, (WPARAM)-1, (LPARAM) ((LPSTR) "Application/PostScript"));
  681.     else if (!_stricmp (temp, "txt") || !_stricmp (temp, "bat") || !_stricmp (temp,"c") || !_stricmp (temp,"cpp") || !_stricmp (temp,"h"))
  682.         SendDlgItemMessage(hDlg, IDD_CONTENT_TYPE, CB_SELECTSTRING, (WPARAM)-1, (LPARAM) ((LPSTR) "Text/Plain"));
  683.     else
  684.         SendDlgItemMessage(hDlg, IDD_CONTENT_TYPE, CB_SELECTSTRING, (WPARAM)-1, (LPARAM) ((LPSTR) DefaultContentType));
  685.     
  686.     SetDlgItemText (hDlg, IDD_MIME_BOUNDARY, MIMEBoundary);
  687.  
  688.       
  689.       return TRUE;
  690.       break;
  691.  
  692.     case WM_COMMAND:
  693.       switch (wParam)
  694.     {
  695.     case ID_OK:
  696.         AttachInNewArt = IsDlgButtonChecked (hDlg, IDD_ATTACH_NEXT);
  697.       // this feature is only available when posting (not when mailing)
  698.       if (!getWndEdit(WndMails, GetWindow (hDlg, GW_OWNER), MAXMAILWNDS)) 
  699.       {
  700.           ReviewAttach = IsDlgButtonChecked (hDlg, IDD_REVIEW);
  701.           if (!ReviewAttach && CcByMail && CcAddress[0])
  702.           {
  703.               if (MessageBox (hDlg, "Cc By Mail will only operate correctly if you enable Review before posting.  Would you like enable Review before posting?", "Attachment Usage Suggestion", MB_YESNOCANCEL|MB_ICONINFORMATION) == IDYES)
  704.                  ReviewAttach = TRUE;
  705.               else 
  706.               {
  707.                   MessageBox (hDlg, "Cc By Mail disabled", "Warning", MB_OK);
  708.                   CcByMail = FALSE;
  709.               }
  710.           }
  711.       }
  712.       if (ProcessEncodingOptions (hDlg) == FAIL)
  713.           break;
  714.         
  715.       GetDlgItemText (hDlg, IDD_ARTICLE_SPLIT_LENGTH, temp, MAXINTERNALLINE);
  716.              if (!_stricmp (temp, "None"))
  717.         ArticleSplitLength = 0;
  718.       else    
  719.           if (isnumber (temp))
  720.         {
  721.             newLen = atol (temp);
  722.             if (newLen <= 0 || newLen > MAXPOSTLENGTH)
  723.             {
  724.                   sprintf (temp, "The article split length must be between 1 and %u", MAXPOSTLENGTH);
  725.                   MessageBox (hDlg, temp, "Article Split Length Error", MB_OK);
  726.                   break;                                                                                                          
  727.               }
  728.               ArticleSplitLength = (unsigned int) newLen;
  729.         }
  730.         else
  731.         {
  732.               MessageBox (hDlg, "The article split length must be a NUMBER of bytes", "Article Split Length Error", MB_OK);
  733.               break;                                                                                                          
  734.           }
  735.         
  736.       
  737.       GetDlgItemText (hDlg, IDD_SUBJECT_TEMPLATE, SubjectTemplate, MAXINTERNALLINE);
  738.  
  739.         GenerateMIME = IsDlgButtonChecked (hDlg, IDD_GENERATE_MIME);
  740.       GetDlgItemText (hDlg, IDD_MIME_BOUNDARY, MIMEBoundary, MAXBOUNDARYLEN);
  741.       // *** should check here that characters in boundary are all valid
  742.       GetDlgItemText (hDlg, IDD_CONTENT_TYPE, (LPSTR) ContentType, MAXINTERNALLINE);
  743.           if (IsDlgButtonChecked (hDlg, IDD_MAKE_DEFAULT))
  744.             strcpy (DefaultContentType, ContentType);
  745.           
  746.         MIMEUsageSuggestions = IsDlgButtonChecked (hDlg, IDD_MIME_USAGE_SUGGESTIONS);
  747.           if (MIMEUsageSuggestions)
  748.           {
  749.             if (GenerateMIME && EncodingTypeNum != CODE_NONE && EncodingTypeNum != CODE_BASE64)
  750.             {
  751.         sprintf (str, "When using %s encoding, MIME headers are not recommended.\nWould you like to deactivate MIME header generation?", EncodingType);
  752.               result = MessageBox (hDlg, str, "MIME Usage Suggestion", MB_YESNOCANCEL|MB_ICONINFORMATION);
  753.               if (result == IDYES) 
  754.                   GenerateMIME = FALSE;
  755.               else if (result == IDCANCEL)
  756.                   break;
  757.           
  758.             } 
  759.             if (!GenerateMIME && EncodingTypeNum == CODE_BASE64)
  760.             {
  761.               result = MessageBox (hDlg, "When using Base-64 encoding, MIME header generation is recommended.\nWould you like to activate MIME header generation?", 
  762.                             "MIME Usage Suggestion", MB_YESNOCANCEL|MB_ICONINFORMATION);
  763.               if (result == IDYES)    
  764.                   GenerateMIME = TRUE;
  765.               else if (result == IDCANCEL)
  766.                   break;
  767.             }
  768.           }
  769.       EndDialog (hDlg, TRUE);
  770.       break;
  771.  
  772.     case IDD_GENERATE_MIME:
  773.           genMIME = (BOOL)IsDlgButtonChecked (hDlg, IDD_GENERATE_MIME);
  774.           EnableWindow (GetDlgItem (hDlg, IDD_MIME_BOUNDARY), genMIME);
  775.       EnableWindow (GetDlgItem (hDlg, IDD_CONTENT_TYPE), genMIME);
  776.       EnableWindow (GetDlgItem (hDlg, IDD_MAKE_DEFAULT), genMIME);
  777.       break;        
  778.  
  779.     case IDCANCEL:
  780.       EndDialog (hDlg, FALSE);
  781.       break;
  782.  
  783.     default:
  784.       return FALSE;
  785.     }
  786.       break;
  787.  
  788.     default:
  789.       return FALSE;
  790.       break;
  791.     }
  792.   return TRUE;
  793. }
  794. /*-- function WinVnEncodeDlg ---------------------------------------
  795.  *
  796.  *  Dialog function to handle encoding to a file
  797.  *  Very similar to WinVnAttachDlg
  798.  *  (JSC)
  799.  */
  800.  
  801. BOOL FAR PASCAL 
  802. WinVnEncodeDlg (hDlg, iMessage, wParam, lParam)
  803.      HWND hDlg;
  804.      unsigned iMessage;
  805.      WORD wParam;
  806.      LONG lParam;
  807. {
  808.   char temp[MAXINTERNALLINE];
  809.   
  810.   switch (iMessage)
  811.     {
  812.     case WM_INITDIALOG:
  813.     sprintf (temp, "Encoding options for file %s", AttachFileName);
  814.     SetWindowText (hDlg, (LPSTR) temp);
  815.  
  816.         SetDlgItemText (hDlg, IDD_FILENAME, AttachFileName);
  817.     SetupEncodingOptions (hDlg);
  818.     return TRUE;
  819.     break;
  820.  
  821.     case WM_COMMAND:
  822.       switch (wParam)
  823.     {
  824.     case ID_OK:
  825.       GetDlgItemText (hDlg, IDD_FILENAME, AttachFileName, MAXFILENAME - 1);
  826.       if (strlen (AttachFileName) == 0)
  827.           {
  828.           MessageBox (hDlg, "Please enter a filename to encode", "Filename error", MB_OK);
  829.           break;                                                                                                          
  830.           }
  831.           
  832.       if (_access(AttachFileName, 0) < 0)
  833.       {
  834.          sprintf(str, "The file %s does not exist", AttachFileName);
  835.          MessageBox (hDlg, str, "Filename error", MB_OK|MB_ICONSTOP);
  836.         break;                                                                                                          
  837.       }
  838.  
  839.       if (ProcessEncodingOptions (hDlg) == FAIL)
  840.           break;
  841.  
  842.       EndDialog (hDlg, TRUE);
  843.       break;
  844.  
  845.     case IDCANCEL:
  846.       EndDialog (hDlg, FALSE);
  847.       break;
  848.  
  849.     case ID_BROWSE:
  850.       if (AskForExistingFileName (hDlg, AttachFileName, "Open file to be encoded") == SUCCESS)
  851.          SetDlgItemText (hDlg, IDD_FILENAME, AttachFileName);
  852.       break;
  853.  
  854.     default:
  855.       return FALSE;
  856.     }
  857.       break;
  858.  
  859.     default:
  860.       return FALSE;
  861.       break;
  862.     }
  863.   return TRUE;
  864. }
  865.  
  866. /*----------------------------------------------------------------------
  867.  * Encoding options functions for use by two dialogs
  868.  * wvattachdlg and wvencodedlg
  869.  * (JSC)
  870.  */
  871. void
  872. SetupEncodingOptions (HWND hDlg)
  873. {
  874.   register int i;
  875.   extern char *EncodingTypes[NUM_ENCODING_TYPES];
  876.  
  877.     // This combo box is NOSORT, so entries can be indexed in order they 
  878.     // added here. But BE CAREFUL!
  879.     for (i = 0; i < NUM_ENCODING_TYPES; i++)
  880.         SendDlgItemMessage(hDlg, IDD_CODING_TYPE,    
  881.             CB_ADDSTRING, 0, (LPARAM) ((LPSTR) EncodingTypes[i]));
  882.  
  883.     if (EncodingTypeToNum (EncodingType) == CODE_UNKNOWN)
  884.         strcpy (EncodingType, "None");
  885.  
  886.     SendDlgItemMessage(hDlg, IDD_CODING_TYPE, CB_SELECTSTRING, (WPARAM)-1, (LPARAM) ((LPSTR) EncodingType));
  887.  
  888.     if (UserCodingTable[0] != '\0')
  889.         SetDlgItemText (hDlg, IDD_CUSTOM_TABLE, UserCodingTable);
  890. }
  891.  
  892. BOOL
  893. ProcessEncodingOptions (HWND hDlg)
  894. {
  895.     char temp[MAXINTERNALLINE];
  896.     int select, x;
  897.     char dummyMap[128];
  898.     
  899.     select = (int)SendDlgItemMessage(hDlg, IDD_CODING_TYPE, CB_GETCURSEL, (WPARAM)0, (LPARAM)0);
  900.     if (select != CB_ERR)
  901.         SendDlgItemMessage(hDlg, IDD_CODING_TYPE,
  902.                    CB_GETLBTEXT, (WPARAM) select, (LPARAM) ((LPSTR) temp));
  903.  
  904.            if (!_stricmp (temp, "Custom"))
  905.         if (GetDlgItemText (hDlg, IDD_CUSTOM_TABLE, UserCodingTable, CODINGTABLESIZE+1))
  906.           {
  907.             if (strlen(UserCodingTable) != CODINGTABLESIZE)
  908.               {
  909.                   MessageBox (hDlg, "Invalid encoding table.  The table must contain 64 characters.", "Custom Encoding Error", MB_OK);
  910.                   return (FAIL);
  911.               }
  912.               if ((x = CreateCodingMap(dummyMap, UserCodingTable)) != -1)
  913.               {
  914.                   sprintf (temp, "Invalid encoding table.  The table must have no duplicate entries (duplicate is %c).", x);
  915.                   MessageBox (hDlg, temp, "Custom Encoding Error", ID_OK);
  916.                   return (FAIL);
  917.               }
  918.           } else {
  919.               MessageBox (hDlg, "To use a custom encoding, you must enter an encoding table", "Custom Encoding Error", MB_OK);
  920.             return (FAIL);
  921.          }
  922.     
  923.     strcpy (EncodingType, temp);
  924.     EncodingTypeNum = EncodingTypeToNum (EncodingType);
  925.               
  926.       return (OK);
  927. }
  928.  
  929. /*-- function WinVnSigFileDlg ---------------------------------------
  930.  *
  931.  *  Dialog function to handle signature files
  932.  *  (JSC 1/8/94)
  933.  */
  934.  
  935. BOOL FAR PASCAL 
  936. WinVnSigFileDlg (hDlg, iMessage, wParam, lParam)
  937.      HWND hDlg;
  938.      unsigned iMessage;
  939.      WORD wParam;
  940.      LONG lParam;
  941. {
  942.   static int MyEnable;
  943.  
  944.   switch (iMessage)
  945.     {
  946.     MyEnable = EnableSig;
  947.  
  948.     case WM_INITDIALOG:
  949.       CheckDlgButton (hDlg, IDD_ENABLE_SIG, EnableSig);
  950.       SetDlgItemText (hDlg, IDD_FILENAME, SigFileName);
  951.       return TRUE;
  952.       break;
  953.  
  954.     case WM_COMMAND:
  955.       switch (wParam)
  956.     {
  957.     case IDOK:
  958.       GetDlgItemText (hDlg, IDD_FILENAME, SigFileName, MAXFILENAME - 1);
  959.  
  960.           ResetTextBlock (Signature);
  961.           if (strlen (SigFileName) == 0)
  962.           {
  963.             EnableSig = FALSE;
  964.             EndDialog (hDlg, TRUE);
  965.             break;
  966.           }
  967.  
  968.       EnableSig = MyEnable;
  969.       if (ReadFileToTextBlock (hDlg, Signature, SigFileName, ADD_PLAIN) == FAIL)
  970.         break;
  971.  
  972.           if (Signature->numLines > BIG_SIG_FILE)
  973.       {
  974.           sprintf (str, "Do you really want a %lu line signature?!?", Signature->numLines);
  975.           if (MessageBox (hDlg, str, "BIG Signature!", MB_YESNO|MB_ICONQUESTION) == IDNO)
  976.           {
  977.           ResetTextBlock (Signature);
  978.           break;
  979.         }
  980.       }          
  981.       EndDialog (hDlg, TRUE);
  982.       break;
  983.  
  984.     case ID_BROWSE:
  985.       if (AskForExistingFileName (hDlg, SigFileName, "Select Signature File") == SUCCESS)
  986.         SetDlgItemText (hDlg, IDD_FILENAME, SigFileName);
  987.       break;
  988.  
  989.     case IDCANCEL:
  990.       EndDialog (hDlg, FALSE);
  991.       break;
  992.  
  993.     case IDD_ENABLE_SIG:
  994.       MyEnable = !MyEnable;
  995.       CheckDlgButton (hDlg, IDD_ENABLE_SIG, MyEnable);
  996.       break;
  997.  
  998.     default:
  999.       return FALSE;
  1000.     }
  1001.       break;
  1002.  
  1003.     default:
  1004.       return FALSE;
  1005.       break;
  1006.     }
  1007.   return TRUE;
  1008. }
  1009.  
  1010. /*-- function WinVnExitDlg---------------------------------------
  1011.  *
  1012.  *  Dialog function to handle exit from WinVn
  1013.  *  Sets globals SaveNewsrc and SaveConfig - leaves actual saving up to caller
  1014.  *  (JSC 1/8/94)
  1015.  */
  1016.  
  1017. BOOL FAR PASCAL 
  1018. WinVnExitDlg (hDlg, iMessage, wParam, lParam)
  1019.      HWND hDlg;
  1020.      unsigned iMessage;
  1021.      WORD wParam;
  1022.      LONG lParam;
  1023. {
  1024.   switch (iMessage)
  1025.     {
  1026.     case WM_INITDIALOG:
  1027.       CheckDlgButton (hDlg, IDD_SAVE_NEWSRC, 1);
  1028.       CheckDlgButton (hDlg, IDD_SAVE_CONFIG, 1);
  1029.       return TRUE;
  1030.       break;
  1031.  
  1032.     case WM_COMMAND:
  1033.       switch (wParam)
  1034.     {
  1035.     case IDOK:
  1036.       SaveNewsrc = IsDlgButtonChecked (hDlg, IDD_SAVE_NEWSRC);
  1037.       SaveConfig = IsDlgButtonChecked (hDlg, IDD_SAVE_CONFIG);
  1038.       EndDialog (hDlg, TRUE);
  1039.       break;
  1040.  
  1041.     case IDCANCEL:
  1042.       EndDialog (hDlg, FALSE);
  1043.       break;
  1044.  
  1045.     default:
  1046.       return FALSE;
  1047.     }
  1048.       break;
  1049.  
  1050.     default:
  1051.       return FALSE;
  1052.       break;
  1053.     }
  1054.   return TRUE;
  1055. }
  1056.  
  1057. /*-- function WinVnFindDlg ---------------------------------------
  1058.  *
  1059.  *  Dialog function to handle Search dialog box.
  1060.  */
  1061.  
  1062. BOOL FAR PASCAL 
  1063. WinVnFindDlg (hDlg, iMessage, wParam, lParam)
  1064.      HWND hDlg;
  1065.      unsigned iMessage;
  1066.      WORD wParam;
  1067.      LONG lParam;
  1068. {
  1069.   static int MyAppend;
  1070.  
  1071.   switch (iMessage)
  1072.     {
  1073.  
  1074.     case WM_INITDIALOG:
  1075.       SetDlgItemText (hDlg, IDD_SEARCH_STRING, FindDoc->SearchStr);
  1076.       return TRUE;
  1077.       break;
  1078.  
  1079.     case WM_COMMAND:
  1080.       switch (wParam)
  1081.    {
  1082.    case IDOK:
  1083.      GetDlgItemText (hDlg, IDD_SEARCH_STRING, FindDoc->SearchStr, MAXFINDSTRING - 1);
  1084.  
  1085.      EndDialog (hDlg, TRUE);
  1086.      break;
  1087.  
  1088.    case IDCANCEL:
  1089.      EndDialog (hDlg, FALSE);
  1090.      break;
  1091.  
  1092.    default:
  1093.      return FALSE;
  1094.    }
  1095.       break;
  1096.  
  1097.     default:
  1098.       return FALSE;
  1099.       break;
  1100.     }
  1101.   return TRUE;
  1102. }
  1103.  
  1104. /*-- function WinVnGenericDlg ---------------------------------------
  1105.  *
  1106.  *  Dialog function to query the user for a posting's subject
  1107.  */
  1108.  
  1109. BOOL FAR PASCAL 
  1110. WinVnGenericDlg (hDlg, iMessage, wParam, lParam)
  1111.      HWND hDlg;
  1112.      unsigned iMessage;
  1113.      WORD wParam;
  1114.      LONG lParam;
  1115. {
  1116.   switch (iMessage)
  1117.     {
  1118.  
  1119.     case WM_INITDIALOG:
  1120.       /* set the prompt, DialogBoxParam passes in lParam */
  1121.       SetDlgItemText (hDlg, IDD_SUBJECT_PROMPT, (char far *) lParam);
  1122.       SetDlgItemText (hDlg, IDD_SUBJECT_STRING, DialogString);
  1123.       return TRUE;
  1124.       break;
  1125.  
  1126.     case WM_COMMAND:
  1127.       switch (wParam)
  1128.    {
  1129.    case IDOK:
  1130.      GetDlgItemText (hDlg, IDD_SUBJECT_STRING, DialogString, 
  1131.                      MAXDIALOGSTRING - 1);
  1132.  
  1133.      EndDialog (hDlg, TRUE);
  1134.      break;
  1135.  
  1136.    case IDCANCEL:
  1137.      EndDialog (hDlg, FALSE);
  1138.      break;
  1139.  
  1140.    default:
  1141.      return FALSE;
  1142.    }
  1143.       break;
  1144.  
  1145.     default:
  1146.       return FALSE;
  1147.       break;
  1148.     }
  1149.   return TRUE;
  1150. }
  1151.  
  1152. /*-- function WinVnSubjectDlg ---------------------------------------
  1153.  *
  1154.  *  Dialog function to query the user for a posting's subject
  1155.  */
  1156.  
  1157. BOOL FAR PASCAL 
  1158. WinVnSubjectDlg (hDlg, iMessage, wParam, lParam)
  1159.      HWND hDlg;
  1160.      unsigned iMessage;
  1161.      WORD wParam;
  1162.      LONG lParam;
  1163. {
  1164.   BOOL useCC;
  1165.   
  1166.   switch (iMessage)
  1167.     {
  1168.     case WM_INITDIALOG:
  1169.       /* disable cc by mail option if this already is a mail composition, 
  1170.          or if mail is disabled, or if mail is not SMTP */
  1171.       if (lParam && MailCtrl.enableMail == MF_ENABLED && MailCtrl.MailType == MT_SMTP) {
  1172.          useCC = CcByMail;
  1173.       } else {
  1174.          EnableWindow (GetDlgItem (hDlg, IDD_CC_BY_MAIL), FALSE);
  1175.          useCC = FALSE;
  1176.       }
  1177.          
  1178.       CheckDlgButton (hDlg, IDD_CC_BY_MAIL, useCC);
  1179.       EnableWindow (GetDlgItem (hDlg, IDD_CC_ADDRESS), useCC);
  1180.       EnableWindow (GetDlgItem (hDlg, ID_BROWSE), useCC);
  1181.       SetDlgItemText (hDlg, IDD_CC_ADDRESS, CcAddress);
  1182.  
  1183.       SetDlgItemText (hDlg, IDD_SUBJECT_STRING, DialogString);
  1184.       if (ReplyTo[0] == '\0')
  1185.          SetDlgItemText (hDlg, IDD_REPLY_TO, MailAddress);
  1186.       else
  1187.          SetDlgItemText (hDlg, IDD_REPLY_TO, ReplyTo);
  1188.  
  1189.  
  1190.       return TRUE;
  1191.       break;
  1192.  
  1193.     case WM_COMMAND:
  1194.       switch (wParam)
  1195.    {
  1196.  
  1197.    case ID_BROWSE:
  1198.     GetDlgItemText (hDlg, IDD_CC_ADDRESS, DialogString, MAXDIALOGSTRING-1); /* set default in mail address box */
  1199.     if (DialogBox (hInst, "WinVnMail", hWndConf, lpfnWinVnMailDlg))
  1200.       SetDlgItemText (hDlg, IDD_CC_ADDRESS, DialogString);
  1201.     break;
  1202.       
  1203.      
  1204.    case IDD_CC_BY_MAIL:
  1205.      CcByMail = IsDlgButtonChecked (hDlg, IDD_CC_BY_MAIL);
  1206.      EnableWindow (GetDlgItem (hDlg, IDD_CC_ADDRESS), CcByMail);
  1207.      EnableWindow (GetDlgItem (hDlg, ID_BROWSE), CcByMail);
  1208.      break;
  1209.  
  1210.    case IDOK:
  1211.      GetDlgItemText (hDlg, IDD_SUBJECT_STRING, DialogString, 
  1212.                      MAXDIALOGSTRING - 1);
  1213.      GetDlgItemText (hDlg, IDD_REPLY_TO, str, MAXDIALOGSTRING - 1);
  1214.      if (str[0] == '\0' || !strcmp (str, MailAddress))
  1215.         ReplyTo[0] = '\0';
  1216.      else      
  1217.         strcpy (ReplyTo, str);
  1218.  
  1219.      CcByMail = IsDlgButtonChecked (hDlg, IDD_CC_BY_MAIL);
  1220.      if (CcByMail)
  1221.        GetDlgItemText (hDlg, IDD_CC_ADDRESS, CcAddress, MAXDIALOGSTRING-1);
  1222.  
  1223.      EndDialog (hDlg, TRUE);
  1224.      break;
  1225.  
  1226.    case IDCANCEL:
  1227.      EndDialog (hDlg, FALSE);
  1228.      break;
  1229.  
  1230.    default:
  1231.      return FALSE;
  1232.    }
  1233.       break;
  1234.  
  1235.     default:
  1236.       return FALSE;
  1237.       break;
  1238.     }
  1239.   return TRUE;
  1240. }
  1241. /*-- function WinVnDoListDlg ---------------------------------------
  1242.  *
  1243.  *  Dialog function to ask whether we should check for new
  1244.  *  newsgroups.
  1245.  */
  1246.  
  1247. BOOL FAR PASCAL 
  1248. WinVnDoListDlg (hDlg, iMessage, wParam, lParam)
  1249.      HWND hDlg;
  1250.      unsigned iMessage;
  1251.      WORD wParam;
  1252.      LONG lParam;
  1253. {
  1254.  
  1255.   switch (iMessage)
  1256.     {
  1257.  
  1258.     case WM_COMMAND:
  1259.       switch (wParam)
  1260.    {
  1261.    case IDOK:
  1262.  
  1263.      EndDialog (hDlg, TRUE);
  1264.      break;
  1265.  
  1266.    case IDCANCEL:
  1267.  
  1268.      EndDialog (hDlg, FALSE);
  1269.      break;
  1270.  
  1271.    default:
  1272.      return FALSE;
  1273.    }
  1274.       break;
  1275.  
  1276.     default:
  1277.       return FALSE;
  1278.       break;
  1279.     }
  1280.   return TRUE;
  1281. }
  1282.  
  1283.  
  1284. /*--- Function WinVnPersonalInfoDlg ----------------------------------
  1285.  *
  1286.  *  Dialog function to obtain personal configuration info
  1287.  *  (Name, email address, etc.) from the user.
  1288.  */
  1289.  
  1290. BOOL FAR PASCAL 
  1291. WinVnPersonalInfoDlg (hDlg, iMessage, wParam, lParam)
  1292.      HWND hDlg;
  1293.      unsigned iMessage;
  1294.      WORD wParam;
  1295.      LONG lParam;
  1296. {
  1297. #define MAXSTR  32
  1298.  
  1299.   int write_ini = FALSE;
  1300.   int dialog_val;
  1301.  
  1302.   switch (iMessage)
  1303.     {
  1304.  
  1305.     case WM_INITDIALOG:
  1306.  
  1307.       SetDlgItemText (hDlg, ID_CONFIG_EMAIL, MailAddress);
  1308.       SetDlgItemText (hDlg, ID_CONFIG_NAME, UserName);
  1309.       SetDlgItemText (hDlg, ID_CONFIG_ORG, Organization);
  1310.       return TRUE;
  1311.       break;
  1312.  
  1313.     case WM_COMMAND:
  1314.       switch (wParam)
  1315.    {
  1316.    case ID_OK_SAVE:
  1317.      write_ini = TRUE;
  1318.    case IDOK:
  1319.      GetDlgItemText (hDlg, ID_CONFIG_NAME, UserName, MAILLEN - 1);
  1320.      GetDlgItemText (hDlg, ID_CONFIG_EMAIL, MailAddress, MAILLEN - 1);
  1321.      GetDlgItemText (hDlg, ID_CONFIG_ORG, Organization, MAILLEN - 1);
  1322.  
  1323. /*   if (write_ini)          (JSC - Now save on exit of app)
  1324.        {
  1325.          WritePrivateProfileString (szAppName, "UserName", UserName, szAppProFile);
  1326.          WritePrivateProfileString (szAppName, "MailAddress", MailAddress, szAppProFile);
  1327.          WritePrivateProfileString (szAppName, "Organization", Organization, szAppProFile);
  1328.        }
  1329. */   dialog_val = TRUE;
  1330.      goto endit;
  1331.      break;
  1332.  
  1333.    case IDCANCEL:
  1334.      dialog_val = FALSE;
  1335.    endit:;
  1336.      EndDialog (hDlg, dialog_val);
  1337.      break;
  1338.  
  1339.    default:
  1340.      return FALSE;
  1341.    }
  1342.       break;
  1343.  
  1344.     default:
  1345.       return FALSE;
  1346.       break;
  1347.     }
  1348.   return TRUE;
  1349. }
  1350.  
  1351.  
  1352.  
  1353. /*--- Function WinVnMiscDlg ---------------------------------------------
  1354.  *
  1355.  *  Dialog function to obtain miscellaneous configuration info
  1356.  *  (whether we should open a new window for each group, etc.)
  1357.  *  from the user.
  1358.  */
  1359.  
  1360. BOOL FAR PASCAL 
  1361. WinVnMiscDlg (hDlg, iMessage, wParam, lParam)
  1362.      HWND hDlg;
  1363.      unsigned iMessage;
  1364.      WORD wParam;
  1365.      LONG lParam;
  1366. {
  1367.   int write_ini = FALSE;
  1368.   int dialog_val;
  1369.   int item;
  1370.   int temp;
  1371.   char threshold[5];
  1372.   static int MyFullSubject;
  1373.  
  1374.   switch (iMessage)
  1375.     {
  1376.  
  1377.     case WM_INITDIALOG:
  1378.       CheckRadioButton (hDlg, ID_DOLIST_BASE, ID_DOLIST_ASK, DoList + ID_DOLIST_BASE);
  1379.       CheckDlgButton (hDlg, ID_CONFIG_APPEND, SaveArtAppend);
  1380.       CheckDlgButton (hDlg, ID_CONFIG_NEW_WND_GROUP, ViewNew);
  1381.       CheckDlgButton (hDlg, ID_CONFIG_NEW_WND_ARTICLE, NewArticleWindow);
  1382. /*    CheckDlgButton (hDlg, ID_CONFIG_ARTICLE_FIXED_FONT, ArticleFixedFont); */
  1383.       CheckDlgButton (hDlg, ID_CONFIG_FULLNAMEFROM, FullNameFrom);
  1384.       CheckDlgButton (hDlg, ID_CONFIG_THREADS, threadp);  
  1385.       CheckDlgButton (hDlg, ID_CONFIG_THREADS_FULL_SUBJECT, ThreadFullSubject);
  1386.       CheckDlgButton (hDlg, ID_CONFIG_SHOWUNSUB, ShowUnsubscribed);
  1387.       CheckDlgButton (hDlg, ID_CONFIG_CONFIRM_BATCH, ConfirmBatchOps);
  1388.       CheckDlgButton (hDlg, ID_CONFIG_CONFIRM_EXIT, ConfirmExit);
  1389.       CheckDlgButton (hDlg, ID_CONFIG_CONFIRM_REPLY_TO, ConfirmReplyTo);
  1390.       CheckDlgButton (hDlg, ID_CONFIG_GROUP_MULTI_SELECT, GroupMultiSelect);
  1391.       CheckDlgButton (hDlg, ID_CONFIG_CONNECT_AT_START, ConnectAtStartup);
  1392.       CheckDlgButton (hDlg, IDD_EXECUTE_DECODED, ExecuteDecodedFiles);
  1393.       CheckDlgButton (hDlg, ID_CONFIG_SHOWUNREADONLY, ShowUnreadOnly);
  1394.       MyFullSubject = ThreadFullSubject;
  1395.       
  1396.       sprintf (threshold, "%d", article_threshold);
  1397.       SetDlgItemText (hDlg, IDD_ART_THRESHOLD, threshold);
  1398.  
  1399.       return TRUE;
  1400.       break;
  1401.  
  1402.     case WM_COMMAND:
  1403.       switch (wParam)
  1404.    {
  1405.    case ID_OK_SAVE:
  1406.      write_ini = TRUE;
  1407.    case IDOK:
  1408.      SaveArtAppend = (IsDlgButtonChecked (hDlg, ID_CONFIG_APPEND) != 0);
  1409.      ViewNew = (IsDlgButtonChecked (hDlg, ID_CONFIG_NEW_WND_GROUP) != 0);
  1410.      NewArticleWindow = (IsDlgButtonChecked (hDlg, ID_CONFIG_NEW_WND_ARTICLE) != 0);
  1411.      FullNameFrom = (IsDlgButtonChecked (hDlg, ID_CONFIG_FULLNAMEFROM) != 0); 
  1412.      ConfirmBatchOps = (IsDlgButtonChecked (hDlg, ID_CONFIG_CONFIRM_BATCH) != 0); 
  1413.      ConfirmExit = (IsDlgButtonChecked (hDlg, ID_CONFIG_CONFIRM_EXIT) != 0); 
  1414.      ConfirmReplyTo = (IsDlgButtonChecked (hDlg, ID_CONFIG_CONFIRM_REPLY_TO) != 0); 
  1415.      ThreadFullSubject = (IsDlgButtonChecked (hDlg, ID_CONFIG_THREADS_FULL_SUBJECT) != 0);
  1416.      GroupMultiSelect = (IsDlgButtonChecked (hDlg, ID_CONFIG_GROUP_MULTI_SELECT) != 0);
  1417.      ConnectAtStartup = (IsDlgButtonChecked (hDlg, ID_CONFIG_CONNECT_AT_START) != 0);
  1418.      ExecuteDecodedFiles = (IsDlgButtonChecked (hDlg, IDD_EXECUTE_DECODED) != 0);
  1419.      ShowUnreadOnly   = (IsDlgButtonChecked (hDlg, ID_CONFIG_SHOWUNREADONLY) != 0);
  1420.      if (ThreadFullSubject != MyFullSubject)
  1421.        RefreshGroupWnds();
  1422.  
  1423. /*   ArticleFixedFont = (IsDlgButtonChecked (hDlg, ID_CONFIG_ARTICLE_FIXED_FONT) != 0);
  1424.      if (ArticleFixedFont != MyArticleFixedFont) {
  1425.        InitArticleFonts();
  1426.        RefreshArticleWnds();
  1427.      }
  1428. */     
  1429.      /* If the user has changed the ShowUnsubscribed option, we must
  1430.       * recompute which lines are active and redisplay.  
  1431.       * Reset the window to the top to make sure that everything
  1432.       * will display OK.
  1433.       * There is some question in my mind whether this code will
  1434.       * work OK if the first screen's worth of groups are unsubscribed,
  1435.       * but it *should* work.
  1436.       */
  1437.      temp = (IsDlgButtonChecked (hDlg,ID_CONFIG_SHOWUNSUB) != 0);
  1438.      if(temp != ShowUnsubscribed) {
  1439.       ShowUnsubscribed = temp;
  1440.       NetDoc.LongestLine = 0;
  1441.       SetGroupActiveLines();
  1442.       ScreenToTop(&NetDoc);              
  1443.       InvalidateRect(hWndConf,NULL,FALSE);
  1444.      }
  1445.      
  1446.      threadp = (IsDlgButtonChecked (hDlg, ID_CONFIG_THREADS) != 0);
  1447.      GetDlgItemText(hDlg,IDD_ART_THRESHOLD,threshold,5);
  1448.  
  1449.      /* 0 or a bogus value means they don't want a threshold */
  1450.      article_threshold = atoi (threshold);
  1451.      if (!article_threshold)
  1452.        article_threshold = INT_MAX;
  1453.  
  1454.      for (item = ID_DOLIST_BASE; item <= ID_DOLIST_ASK; item++)
  1455.        {
  1456.          if (IsDlgButtonChecked (hDlg, item))
  1457.          {
  1458.            DoList = item - ID_DOLIST_BASE;
  1459.          }
  1460.        }
  1461.  
  1462. /*  if (write_ini)         (JSC - Now save on exit of app)
  1463.     {
  1464.       WritePrivateProfileInt
  1465.     (szAppName, "SaveArtAppend", SaveArtAppend, szAppProFile);
  1466.       WritePrivateProfileInt
  1467.     (szAppName, "NewWndGroup", ViewNew, szAppProFile);
  1468.       WritePrivateProfileInt
  1469.     (szAppName, "NewWndArticle", NewArticleWindow, szAppProFile);
  1470.       WritePrivateProfileInt
  1471.     (szAppName, "DoList", DoList, szAppProFile);
  1472.       WritePrivateProfileInt
  1473.     (szAppName, "ArticleFixedFont", ArticleFixedFont, szAppProFile);
  1474.       WritePrivateProfileInt
  1475.     (szAppName, "ArticleThreshold", article_threshold, szAppProFile);
  1476.       WritePrivateProfileInt
  1477.     (szAppName, "FullNameFrom", FullNameFrom, szAppProFile);
  1478.       WritePrivateProfileInt
  1479.         (szAppName, "EnableThreading", threadp, szAppProFile);
  1480.       WritePrivateProfileInt
  1481.         (szAppName, "ShowUnsubscribed", ShowUnsubscribed, szAppProFile);
  1482.     }
  1483. */  dialog_val = TRUE;
  1484.     goto endit;
  1485.     break;
  1486.  
  1487.    case IDCANCEL:
  1488.      dialog_val = FALSE;
  1489.    endit:;
  1490.      EndDialog (hDlg, dialog_val);
  1491.      break;
  1492.  
  1493.    default:
  1494.      return FALSE;
  1495.    }
  1496.       break;
  1497.  
  1498.     default:
  1499.       return FALSE;
  1500.       break;
  1501.     }
  1502.   return TRUE;
  1503.  
  1504. }
  1505.  
  1506. /*-- function WinVnThresholdDlg ---------------------------------------
  1507.  *
  1508.  *  Dialog function to ask how many article headers we
  1509.  *  want to retrieve.
  1510.  */
  1511.  
  1512. BOOL FAR PASCAL 
  1513. WinVnThresholdDlg (hDlg, iMessage, wParam, lParam)
  1514.      HWND hDlg;
  1515.      unsigned iMessage;
  1516.      WORD wParam;
  1517.      LONG lParam;
  1518. {
  1519.  
  1520.   char manual[6];
  1521.  
  1522.   switch (iMessage)
  1523.     {
  1524.  
  1525.     case WM_INITDIALOG:
  1526.         sprintf (str, "%u articles in group", arts_to_retrieve);
  1527.         SetWindowText(hDlg, (LPCSTR)str);
  1528.     break;
  1529.     case WM_COMMAND:
  1530.       switch (wParam)
  1531.    {
  1532.    case ID_OK:
  1533.      GetDlgItemText (hDlg, IDD_ARTS_TO_GRAB, manual, 6);
  1534.      arts_to_retrieve = (unsigned int) atoi (manual);
  1535.      if (arts_to_retrieve > 0)
  1536.        EndDialog (hDlg, TRUE);
  1537.      break;
  1538.  
  1539.    case ID_CANCEL:
  1540.      EndDialog (hDlg, FALSE);
  1541.      break;
  1542.      
  1543.    case ID_100_ARTS:
  1544.  
  1545.      arts_to_retrieve = 100;
  1546.      EndDialog (hDlg, TRUE);
  1547.      break;
  1548.  
  1549.    case ID_250_ARTS:
  1550.  
  1551.      arts_to_retrieve = 250;
  1552.      EndDialog (hDlg, TRUE);
  1553.      break;
  1554.  
  1555.    case ID_500_ARTS:
  1556.  
  1557.      arts_to_retrieve = 500;
  1558.      EndDialog (hDlg, TRUE);
  1559.      break;
  1560.  
  1561.    case ID_THRESHOLD_ALL:
  1562.      arts_to_retrieve = -1;
  1563.      EndDialog (hDlg, TRUE);
  1564.      break;
  1565.      
  1566.    case ID_THRESHOLD_UNREAD:
  1567.      arts_to_retrieve = -2;
  1568.      EndDialog (hDlg, TRUE);
  1569.      break;
  1570.  
  1571.    default:
  1572.      return FALSE;
  1573.    }
  1574.       break;
  1575.  
  1576.     default:
  1577.       return FALSE;
  1578.       break;
  1579.     }
  1580.   return TRUE;
  1581. }
  1582.  
  1583.  
  1584. /*--- Function WinVnAppearanceDlg ----------------------------------
  1585.  *
  1586.  *  Dialog function to obtain window appearance configuration info
  1587.  *  (font, color, etc.)
  1588.  *  from the user.
  1589.  */
  1590.  
  1591. BOOL FAR PASCAL 
  1592. WinVnAppearanceDlg (hDlg, iMessage, wParam, lParam)
  1593.      HWND hDlg;
  1594.      unsigned iMessage;
  1595.      WORD wParam;
  1596.      LONG lParam;
  1597. {
  1598.   return (TRUE);
  1599. }
  1600.  
  1601. BOOL FAR PASCAL
  1602. WinVnLogOptDlg (hDlg, iMessage, wParam, lParam)
  1603.      HWND hDlg;
  1604.      unsigned iMessage;
  1605.      WORD wParam;
  1606.      LONG lParam;
  1607. {
  1608.   int write_ini = FALSE;
  1609.   static int SaveMailLog, SavePostLog ;
  1610.   char fileName[MAXFILENAME];
  1611.  
  1612.   switch (iMessage)
  1613.     {
  1614.  
  1615.     case WM_INITDIALOG:
  1616.       SaveMailLog = MailLog ;
  1617.       SavePostLog = PostLog ;
  1618.       CheckDlgButton (hDlg, IDD_MAILLOG, SaveMailLog);
  1619.       CheckDlgButton (hDlg, IDD_POSTLOG, SavePostLog);
  1620.       SetDlgItemText (hDlg, IDD_MAILNAME, MailLogFile);
  1621.       SetDlgItemText (hDlg, IDD_POSTNAME, PostLogFile);
  1622. //   EnableWindow(GetDlgItem(hDlg,IDD_MAILNAME),SaveMailLog);
  1623.       EnableWindow(GetDlgItem(hDlg,IDD_POSTNAME),SavePostLog);
  1624.   /* mail logging only works for non mapi at present */
  1625.      EnableWindow(GetDlgItem(hDlg,IDD_MAILLOG),(MailCtrl.MailType != MT_MAPI));
  1626.      EnableWindow(GetDlgItem(hDlg,IDD_MAILNAME),
  1627.        (MailCtrl.MailType != MT_MAPI)&&SaveMailLog);
  1628.  
  1629.       return TRUE;
  1630.       break;
  1631.  
  1632.     case WM_COMMAND:
  1633.       switch (wParam)
  1634.    {
  1635.    case ID_OK_SAVE:
  1636.      write_ini = TRUE;
  1637.    case IDOK:
  1638.      GetDlgItemText (hDlg,  IDD_MAILNAME, MailLogFile, MAXFILENAME - 1);
  1639.      GetDlgItemText (hDlg,  IDD_POSTNAME, PostLogFile, MAXFILENAME - 1);
  1640.  
  1641.      MailLog = SaveMailLog;
  1642.           PostLog = SavePostLog;
  1643. /*        Should we check sensibility of files before exiting ?
  1644.      if (!MRRWriteDocument (ActiveArticleDoc, sizeof (TypText), SaveArtFileName, SaveArtAppend))
  1645.        {
  1646.          MessageBox (hWndConf, "Could not write to file", "Problems saving file", MB_OK | MB_ICONEXCLAMATION);
  1647.        }
  1648. */
  1649. /*  if (write_ini)    (JSC - now save on exit of app)
  1650.     {
  1651.       WritePrivateProfileString
  1652.     (szAppName, "MailLogFile", MailLogFile, szAppProFile);
  1653.       WritePrivateProfileString
  1654.     (szAppName, "PostLogFile", PostLogFile, szAppProFile);
  1655.       WritePrivateProfileInt (szAppName, "MailLog",
  1656.          MailLog, szAppProFile);
  1657.       WritePrivateProfileInt (szAppName, "PostLog",
  1658.          PostLog, szAppProFile);
  1659.        }
  1660. */
  1661.       EndDialog (hDlg, TRUE);
  1662.       break;
  1663.  
  1664.     case IDCANCEL:
  1665.       EndDialog (hDlg, FALSE);
  1666.       break;
  1667.  
  1668.    case ID_BROWSEPOST:
  1669.      fileName[0]='\0';
  1670.      if (AskForNewFileName (hDlg, fileName, "", FALSE) == SUCCESS)
  1671.        SetDlgItemText (hDlg, IDD_POSTNAME, fileName);
  1672.      break;
  1673.  
  1674.    case ID_BROWSEMAIL:
  1675.      fileName[0]='\0';
  1676.      if (AskForNewFileName (hDlg, fileName, "", FALSE) == SUCCESS)
  1677.        SetDlgItemText (hDlg, IDD_MAILNAME, fileName);
  1678.      break;
  1679.  
  1680.     case IDD_MAILLOG:
  1681.       SaveMailLog = !SaveMailLog;
  1682.       CheckDlgButton (hDlg, IDD_MAILLOG, SaveMailLog);
  1683.       EnableWindow(GetDlgItem(hDlg,IDD_MAILNAME),SaveMailLog);
  1684.       break;
  1685.     case IDD_POSTLOG:
  1686.       SavePostLog = !SavePostLog;
  1687.       CheckDlgButton (hDlg, IDD_POSTLOG, SavePostLog);
  1688.       EnableWindow(GetDlgItem(hDlg,IDD_POSTNAME),SavePostLog);
  1689.       break;
  1690.  
  1691.     default:
  1692.       return FALSE;
  1693.     }
  1694.       break;
  1695.  
  1696.     default:
  1697.       return FALSE;
  1698.       break;
  1699.     }
  1700.   return TRUE;
  1701. }
  1702.  
  1703. /*-- function WinVnMailDialog ---------------------------------------
  1704.  *
  1705.  *  Dialog function to query for mail destination, and manage list
  1706.  *  of mail addresses
  1707.  *  (JSC 2/1/94)
  1708.  */
  1709.  
  1710. BOOL FAR PASCAL 
  1711. WinVnMailDlg (hDlg, iMessage, wParam, lParam)
  1712.      HWND hDlg;
  1713.      unsigned iMessage;
  1714.      WPARAM wParam;
  1715.      LPARAM lParam;
  1716. {
  1717.   static HWND hMailList;       /* Handle to child list box window. */
  1718.   register int j; 
  1719.   int count, len, startLen, found;
  1720.   char *ptr;
  1721.   char mybuf[MAXDIALOGSTRING];
  1722.  
  1723.   switch (iMessage)
  1724.     {
  1725.     case WM_INITDIALOG:
  1726.       hMailList = GetDlgItem (hDlg, IDD_MAIL_LIST);
  1727.  
  1728.       SendMessage (hMailList, WM_SETREDRAW, FALSE, 0L);
  1729.       for (j = 0; j < (int)MailList->numLines; j++)
  1730.     SendMessage (hMailList, LB_ADDSTRING, 0, (LPARAM) ((LPSTR) TextBlockLine (MailList, j)));
  1731.  
  1732.       SendMessage (hMailList, WM_SETREDRAW, TRUE, 0L);
  1733.       EnableWindow (GetDlgItem (hDlg, IDD_DELETE), FALSE);
  1734.       EnableWindow (GetDlgItem (hDlg, IDD_ADD), FALSE);
  1735.       return TRUE;
  1736.       break;
  1737.  
  1738.     case WM_COMMAND:
  1739.       switch (LOWORD(wParam))
  1740.       {
  1741.       case IDD_MAIL_LIST:
  1742.         switch (GET_WM_COMMAND_CMD(wParam,lParam))
  1743.         {
  1744.         case LBN_SELCHANGE:
  1745.            EnableWindow (GetDlgItem (hDlg, IDD_DELETE), TRUE);
  1746.            break;
  1747.  
  1748.         case LBN_DBLCLK:
  1749.         // a double click means they want to add a name to the to-line
  1750.         // only add it if it's not already on the to-line
  1751.  
  1752.         j = (int)SendMessage (hMailList, LB_GETCARETINDEX, 0, 0L);
  1753.         SendMessage (hMailList, LB_GETTEXT, j, (LPARAM) ((LPSTR) mybuf));
  1754.  
  1755.         GetDlgItemText (hDlg, IDD_MAIL_DEST, DialogString, MAXDIALOGSTRING-1);
  1756.         strcpy (str, DialogString);
  1757.     // test if name already on "To:" line
  1758.     // can't to a test with strstr() because mybuf may be a substring
  1759.     // of another address (i.e. 'jcoop' is a substr of 'jcooper@apl.com')
  1760.         for (found = FALSE, ptr = str; *ptr; ptr += len + 1)
  1761.         {                                         
  1762.           // if there's only one token left, then len will = startLen, 
  1763.           // and we'll iterate once only
  1764.           startLen = strlen (ptr);
  1765.           if ((len = strcspn (ptr, " ,\n\t\r")) != startLen)
  1766.           { 
  1767.             ptr[len] = '\0';            // replace delim with NULL char
  1768.             while (strchr (" ,\n\t\r", ptr[len+1]))    // eat white space
  1769.               ptr[len++] = '\0';
  1770.           }
  1771.       if (!strcmp (ptr, mybuf))
  1772.           {
  1773.         found = TRUE;
  1774.         break;
  1775.       }
  1776.           if (len == startLen)        // last token, we're done
  1777.             break;
  1778.     }          
  1779.         if (!found)
  1780.     {
  1781.           if (strlen (mybuf) + strlen (DialogString) + 2 > MAXDIALOGSTRING-1)
  1782.       {
  1783.         MessageBox (hDlg, "Cannot add another address", "Address line is too long", MB_OK);                
  1784.             return FALSE;
  1785.           }
  1786.           if (DialogString[0])    // if this isn't the first one, prepend a comma
  1787.             strcat (DialogString, ", ");
  1788.           strcat (DialogString, mybuf);
  1789.           SetDlgItemText (hDlg, IDD_MAIL_DEST, DialogString);
  1790.         }
  1791.        }
  1792.     break;               
  1793.  
  1794.       case IDD_MAIL_DEST:
  1795.         GetDlgItemText (hDlg, IDD_MAIL_DEST, mybuf, MAXDIALOGSTRING-1);
  1796.         EnableWindow (GetDlgItem (hDlg, IDD_ADD), mybuf[0]);
  1797.         return FALSE;    /* let default handler act on these events */
  1798.         break;
  1799.  
  1800.       case IDD_ADD:
  1801.     // check addresses listed on to-line, add each one to list box 
  1802.     // (if not already in the list)
  1803.         GetDlgItemText (hDlg, IDD_MAIL_DEST, DialogString, MAXDIALOGSTRING-1);
  1804.         for (ptr = DialogString; *ptr; ptr += len + 1)
  1805.         {                                         
  1806.           // if there's only one token left, then len will = startLen, 
  1807.           // and we'll iterate once only
  1808.           startLen = strlen (ptr);
  1809.           if ((len = strcspn (ptr, " ,\n\t\r")) != startLen)
  1810.           { 
  1811.             ptr[len] = '\0';            // replace delim with NULL char
  1812.             while (strchr (" ,\n\t\r", ptr[len+1]))    // eat white space
  1813.               ptr[len++] = '\0';
  1814.           }
  1815.           if (*ptr != '\0')    // if not a blank
  1816.           {
  1817.             // check if it's already in the list
  1818.             count = (int)SendMessage (hMailList, LB_GETCOUNT, 0, 0L);
  1819.             for (j = 0; j < count; j++)
  1820.             {
  1821.               SendMessage (hMailList, LB_GETTEXT, j, (LPARAM) ((LPSTR) mybuf));
  1822.               if (!stricmp (ptr, mybuf))
  1823.                 break;
  1824.             }
  1825.             if (j == count)        // if not already in list, add it
  1826.               SendMessage (hMailList, LB_ADDSTRING, 0, (LPARAM) ((LPSTR) ptr));
  1827.           }          
  1828.           if (len == startLen)        // last token, we're done
  1829.             break;
  1830.         }          
  1831.        break;
  1832.             
  1833.       case IDD_DELETE:
  1834.     // remove all selected addresses from list box
  1835.         count = (int)SendMessage (hMailList, LB_GETCOUNT, 0, 0L);
  1836.         
  1837.     SendMessage (hMailList, WM_SETREDRAW, FALSE, 0L);
  1838.     
  1839.     // working backwards, delete selected items
  1840.         for (j = count-1; j >= 0; j--)
  1841.           if (SendMessage (hMailList, LB_GETSEL, j, 0L))
  1842.             SendMessage (hMailList, LB_DELETESTRING, j, 0L);
  1843.  
  1844.         SendMessage (hMailList, WM_SETREDRAW, TRUE, 0L);
  1845.         EnableWindow (GetDlgItem (hDlg, IDD_DELETE), FALSE);
  1846.         break;
  1847.      
  1848.       case IDOK:
  1849.         GetDlgItemText (hDlg, IDD_MAIL_DEST, mybuf, MAXDIALOGSTRING-1);
  1850.     
  1851.     // make sure the address (if more than one) is comma separated
  1852.     DialogString[0]='\0';  
  1853.         for (ptr = mybuf; *ptr; ptr += len + 1)
  1854.         {                                         
  1855.           // if there's only one token left, then len will = startLen, 
  1856.           // and we'll iterate once only
  1857.           startLen = strlen (ptr);
  1858.           if ((len = strcspn (ptr, " ,\n\t\r")) != startLen)
  1859.           { 
  1860.             ptr[len] = '\0';            // replace delim with NULL char
  1861.             while (strchr (" ,\n\t\r", ptr[len+1]))    // eat white space
  1862.               ptr[len++] = '\0';
  1863.           }
  1864.       
  1865.       strcat (DialogString, ptr);
  1866.           
  1867.           if (len == startLen)        // last token, we're done
  1868.             break;
  1869.           else
  1870.             strcat (DialogString, ", ");
  1871.     }          
  1872.  
  1873.     // commit changes in listbox to internal MailList
  1874.     ResetTextBlock (MailList);
  1875.     count = (int)SendMessage (hMailList, LB_GETCOUNT, 0, 0L);
  1876.         for (j = 0; j < count; j++)
  1877.         {
  1878.       SendMessage (hMailList, LB_GETTEXT, j, (LPARAM) ((LPSTR) mybuf));
  1879.       AddLineToTextBlock (MailList, mybuf);
  1880.     }
  1881.         
  1882.         EndDialog (hDlg, TRUE);
  1883.         break;
  1884.  
  1885.  
  1886.       case IDCANCEL:
  1887.         // changes to MailList are _not_ committed on Cancel
  1888.         EndDialog (hDlg, FALSE);
  1889.         break;
  1890.  
  1891.    default:
  1892.      return FALSE;
  1893.    }
  1894.       break;
  1895.  
  1896.     default:
  1897.       return FALSE;
  1898.       break;
  1899.     }
  1900.   return TRUE;
  1901. }
  1902.                                    
  1903.                                    
  1904. /*-- function WinVnSmartFilerDialog ---------------------------------------
  1905.  *
  1906.  *  Manages smart filer config
  1907.  *  (JSC 9/10/94)
  1908.  */
  1909.  
  1910. BOOL FAR PASCAL 
  1911. WinVnSmartFilerDlg (hDlg, iMessage, wParam, lParam)
  1912.      HWND hDlg;
  1913.      unsigned iMessage;
  1914.      WPARAM wParam;
  1915.      LPARAM lParam;
  1916. {
  1917.   static HWND hSourceList, hDosList;        /* extension mapping comboboxes */
  1918.   static HWND hDupeList, hShortenList;        /* options dropllists */
  1919.   static int MyEnableExtensionConversion;
  1920.   register int j; 
  1921.   int count, n, e;
  1922.   char mybuf[MAXDIALOGSTRING];
  1923.   BOOL ok;
  1924.  
  1925.   switch (iMessage)
  1926.     {
  1927.     case WM_INITDIALOG:
  1928.       hSourceList = GetDlgItem (hDlg, IDD_SOURCE_EXT_LIST);
  1929.       hDosList = GetDlgItem (hDlg, IDD_DOS_EXT_LIST);
  1930.       hDupeList = GetDlgItem (hDlg, IDD_AVOID_DUPES);
  1931.       hShortenList = GetDlgItem (hDlg, IDD_NAME_SHORTEN);
  1932.  
  1933.       SetDlgItemInt (hDlg, IDD_MAX_NAME_LEN, MaxFileNameLen, TRUE);
  1934.       SetDlgItemInt (hDlg, IDD_MAX_EXT_LEN, MaxFileExtLen, TRUE);
  1935.  
  1936.       CheckDlgButton (hDlg, IDD_ENABLE_CONVERSION, EnableExtensionConversion);
  1937.       EnableWindow (hSourceList, EnableExtensionConversion);
  1938.       EnableWindow (hDosList, EnableExtensionConversion);
  1939.       EnableWindow (GetDlgItem (hDlg, IDD_SOURCE_EXT), EnableExtensionConversion);
  1940.       EnableWindow (GetDlgItem (hDlg, IDD_DOS_EXT), EnableExtensionConversion);
  1941.  
  1942.       EnableWindow (GetDlgItem (hDlg, IDD_ADD), FALSE);
  1943.       EnableWindow (GetDlgItem (hDlg, IDD_DELETE), FALSE);
  1944.       
  1945.       SendMessage (hSourceList, WM_SETREDRAW, FALSE, 0L);
  1946.       SendMessage (hDosList, WM_SETREDRAW, FALSE, 0L);
  1947.       SendMessage (hDupeList, WM_SETREDRAW, FALSE, 0L);
  1948.       SendMessage (hShortenList, WM_SETREDRAW, FALSE, 0L);
  1949.       for (j = 0; j < (int)ExtMapSourceList->numLines; j++)
  1950.       {
  1951.         SendMessage (hSourceList, LB_ADDSTRING, 0, (LPARAM)((LPCSTR)TextBlockLine (ExtMapSourceList, j)));
  1952.         SendMessage (hDosList, LB_ADDSTRING, 0, (LPARAM)((LPCSTR)TextBlockLine (ExtMapDosList, j)));
  1953.       }
  1954.       SendMessage (hDupeList, CB_INSERTSTRING, (WPARAM)DUPE_AVOID_NONE, (LPARAM)((LPCSTR)"Prompt for new file name"));
  1955.       SendMessage (hDupeList, CB_INSERTSTRING, (WPARAM)DUPE_AVOID_NUMBER_EXT, (LPARAM)((LPCSTR)"Replace extension with number"));
  1956.       SendMessage (hDupeList, CB_INSERTSTRING, (WPARAM)DUPE_AVOID_PREPEND_NUM, (LPARAM)((LPCSTR)"Preserve extension, prepend number to name"));
  1957.       SendMessage (hDupeList, CB_INSERTSTRING, (WPARAM)DUPE_AVOID_APPEND_NUM, (LPARAM)((LPCSTR)"Preserve extension, append number to name"));
  1958.  
  1959.       SendMessage (hShortenList, CB_INSERTSTRING, (WPARAM)SHORTEN_NONE, (LPARAM)((LPCSTR)"Prompt for new file name"));
  1960.       SendMessage (hShortenList, CB_INSERTSTRING, (WPARAM)SHORTEN_TRUNCATE, (LPARAM)((LPCSTR)"Truncate at max name length"));
  1961.       SendMessage (hShortenList, CB_INSERTSTRING, (WPARAM)SHORTEN_SKIP_VOWELS, (LPARAM)((LPCSTR)"Condense (skip vowels, punctuation)"));
  1962.  
  1963.       MyEnableExtensionConversion = EnableExtensionConversion;
  1964.  
  1965.       SendMessage(hDupeList, CB_SETCURSEL, (WPARAM)OnDupeName, 0L);
  1966.       SendMessage(hShortenList, CB_SETCURSEL, (WPARAM)OnNameTooLong, 0L);
  1967.       
  1968.       SendMessage (hSourceList, WM_SETREDRAW, TRUE, 0L);
  1969.       SendMessage (hDosList, WM_SETREDRAW, TRUE, 0L);
  1970.       SendMessage (hDupeList, WM_SETREDRAW, TRUE, 0L);
  1971.       SendMessage (hShortenList, WM_SETREDRAW, TRUE, 0L);
  1972.       
  1973.       return TRUE;
  1974.       break;
  1975.  
  1976.     case WM_VSCROLL:
  1977.       if ((HWND)lParam == hDosList)
  1978.           DebugBreak();
  1979.       return FALSE;
  1980.       break;      
  1981.                 
  1982.     case WM_COMMAND:
  1983.       switch (LOWORD(wParam))
  1984.       {
  1985.     case IDD_SOURCE_EXT_LIST:
  1986.         switch (GET_WM_COMMAND_CMD(wParam,lParam))
  1987.         {
  1988.         case LBN_SELCHANGE:
  1989.             j = (int)SendMessage (hSourceList, LB_GETCURSEL, 0, 0L);
  1990.             SendMessage (hDosList, LB_SETCURSEL, (WPARAM)j, 0L);
  1991.             EnableWindow (GetDlgItem (hDlg, IDD_DELETE), TRUE);
  1992.             return FALSE;    /* let the default handler do it */
  1993.             break;    
  1994.         }
  1995.         break;
  1996.        case IDD_DOS_EXT_LIST:
  1997.         switch (GET_WM_COMMAND_CMD(wParam,lParam))
  1998.         {
  1999.         case LBN_SELCHANGE:
  2000.             j = (int)SendMessage (hDosList, LB_GETCURSEL, 0, 0L);
  2001.             SendMessage (hSourceList, LB_SETCURSEL, (WPARAM)j, 0L);
  2002.             EnableWindow (GetDlgItem (hDlg, IDD_DELETE), TRUE);
  2003.             return FALSE;    /* let the default handler do it */
  2004.             break;    
  2005.         }
  2006.         break;
  2007.  
  2008.       case IDD_SOURCE_EXT:
  2009.       case IDD_DOS_EXT:
  2010.         GetDlgItemText (hDlg, IDD_SOURCE_EXT, mybuf, MAXDIALOGSTRING-1);
  2011.         GetDlgItemText (hDlg, IDD_DOS_EXT, str, MAXDIALOGSTRING-1);
  2012.         EnableWindow (GetDlgItem (hDlg, IDD_ADD), (str[0] && mybuf[0]));
  2013.         return FALSE;    /* let default handler act on these events */
  2014.         break;
  2015.           
  2016.       case IDD_ADD:
  2017.         GetDlgItemText (hDlg, IDD_SOURCE_EXT, DialogString, MAXDIALOGSTRING-1);
  2018.         GetDlgItemText (hDlg, IDD_DOS_EXT, str, MAXDIALOGSTRING-1);
  2019.  
  2020.         /* check if it's already in the list */
  2021.         count = (int)SendMessage (hSourceList, LB_GETCOUNT, 0, 0L);
  2022.         for (j = 0; j < count; j++)
  2023.         {
  2024.           SendMessage (hSourceList, LB_GETTEXT, (WPARAM)j, (LPARAM) ((LPSTR) mybuf));
  2025.           if (!stricmp (DialogString, mybuf))
  2026.             break;
  2027.         }
  2028.         if (j == count)    {    /* if not already in list, add it */
  2029.           SendMessage (hSourceList, LB_ADDSTRING, 0, (LPARAM) ((LPSTR) DialogString));
  2030.           SendMessage (hDosList, LB_ADDSTRING, 0, (LPARAM) ((LPSTR) str));
  2031.         } else {            /* if already in list, modify the dos ex */
  2032.           SendMessage (hDosList, LB_DELETESTRING, (WPARAM)j, 0L);
  2033.           SendMessage (hDosList, LB_INSERTSTRING, (WPARAM)j, (LPARAM) ((LPSTR) str));
  2034.         }  
  2035.         break;
  2036.             
  2037.       case IDD_DELETE:
  2038.         j = (int)SendMessage(hSourceList, LB_GETCURSEL, 0, 0L);
  2039.         SendMessage(hSourceList, LB_DELETESTRING, (WPARAM)j, 0L);
  2040.         SendMessage(hDosList, LB_DELETESTRING, (WPARAM)j, 0L);
  2041.         EnableWindow (GetDlgItem (hDlg, IDD_DELETE), FALSE);
  2042.         break;
  2043.      
  2044.       case IDOK:
  2045.         n = GetDlgItemInt(hDlg, IDD_MAX_NAME_LEN, &ok, TRUE);
  2046.         e = GetDlgItemInt(hDlg, IDD_MAX_EXT_LEN, &ok, TRUE);
  2047. #ifdef WIN32
  2048.         if (n+e <= 0 || n+e > 255) {
  2049.              MessageBox (hDlg, "Names (name + extension) must be between 1 and 255 characters in length", "File Name Length Error", MB_OK);
  2050.              break;
  2051.         }
  2052.         if (e == 0 && MyEnableExtensionConversion) {
  2053.              if (MessageBox (hDlg, "With max extension length of 0, extension conversion must be disabled.  Continue?", "Warning", MB_YESNO) == IDNO)
  2054.                 break;                           
  2055.             else
  2056.                 MyEnableExtensionConversion = FALSE;
  2057.         }
  2058.         
  2059. #else
  2060.         if (n <=0 || n > 8) {
  2061.              MessageBox (hDlg, "DOS names must be between 0 and 8 characters in length", "File Name Length Error", MB_OK);
  2062.              break;
  2063.         }
  2064.         if (e <= 0 || e > 3) {
  2065.              MessageBox (hDlg, "DOS extensions must be between 0 and 3 characters in length", "File Extension Length Error", MB_OK);
  2066.              break;
  2067.         }
  2068. #endif /* WIN32 */
  2069.         MaxFileNameLen = n;
  2070.         MaxFileExtLen = e;
  2071.         OnDupeName = (int)SendMessage(hDupeList, CB_GETCURSEL, 0, 0L);
  2072.         OnNameTooLong = (int)SendMessage(hShortenList, CB_GETCURSEL, 0, 0L);
  2073.         EnableExtensionConversion = MyEnableExtensionConversion;
  2074.  
  2075.         /* commit changes in listbox to internal lists */
  2076.         ResetTextBlock (ExtMapSourceList);
  2077.         ResetTextBlock (ExtMapDosList);
  2078.         count = (int)SendMessage (hSourceList, LB_GETCOUNT, 0, 0L);
  2079.         for (j = 0; j < count; j++)
  2080.         {
  2081.             SendMessage (hSourceList, LB_GETTEXT, j, (LPARAM) ((LPSTR) mybuf));
  2082.             AddLineToTextBlock (ExtMapSourceList, mybuf);
  2083.             SendMessage (hDosList, LB_GETTEXT, j, (LPARAM) ((LPSTR) mybuf));
  2084.             AddLineToTextBlock (ExtMapDosList, mybuf);
  2085.         }
  2086.             
  2087.         EndDialog (hDlg, TRUE);
  2088.         break;
  2089.  
  2090.  
  2091.       case IDCANCEL:
  2092.         /* changes to lists are _not_ committed on Cancel */
  2093.         EndDialog (hDlg, FALSE);
  2094.         break;
  2095.  
  2096.       case IDD_ENABLE_CONVERSION:
  2097.         MyEnableExtensionConversion = !MyEnableExtensionConversion;
  2098.         CheckDlgButton (hDlg, IDD_ENABLE_CONVERSION, MyEnableExtensionConversion);
  2099.         SendMessage (hSourceList, LB_SETCURSEL, (WPARAM)-1, 0L);    /* deselect */
  2100.         SendMessage (hDosList, LB_SETCURSEL, (WPARAM)-1, 0L);
  2101.         EnableWindow (hSourceList, MyEnableExtensionConversion);
  2102.         EnableWindow (hDosList, MyEnableExtensionConversion);
  2103.         EnableWindow (GetDlgItem (hDlg, IDD_SOURCE_EXT), MyEnableExtensionConversion);
  2104.         EnableWindow (GetDlgItem (hDlg, IDD_DOS_EXT), MyEnableExtensionConversion);
  2105.         if (!MyEnableExtensionConversion) {
  2106.            EnableWindow (GetDlgItem (hDlg, IDD_DELETE), FALSE);
  2107.            EnableWindow (GetDlgItem (hDlg, IDD_DELETE), FALSE);
  2108.         }
  2109.         break;
  2110.  
  2111.    default:
  2112.      return FALSE;
  2113.    }
  2114.       break;
  2115.  
  2116.     default:
  2117.       return FALSE;
  2118.       break;
  2119.     }
  2120.   return TRUE;
  2121. }
  2122.                                    
  2123.